<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台管理系统</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
    <link rel="stylesheet" href="./css/style.css">
</head>
<body>
    <div class="ui_tab">
        <div class="tab_header">
            <button class="tab_btn">基本设置</button>
            <button class="tab_btn">其他信息</button>
            <button class="tab_btn">额外信息</button>
            <div class="line"></div>
        </div>
        <div class="tab_main">
            <div class="tab_content active">
                <h1>基本设置</h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Accusantium assumenda amet repudiandae explicabo voluptatibus officiis, iusto et adipisci eum, a vero? Cumque delectus magnam quibusdam! Quo sequi voluptas eveniet molestias.</p>
            </div>
            <div class="tab_content">
                <h1>其他信息</h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Accusantium assumenda amet repudiandae explicabo voluptatibus officiis, iusto et adipisci eum, a vero? Cumque delectus magnam quibusdam! Quo sequi voluptas eveniet molestias.</p>
            </div>
            <div class="tab_content">
                <h1>额外信息</h1>
                <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Accusantium assumenda amet repudiandae explicabo voluptatibus officiis, iusto et adipisci eum, a vero? Cumque delectus magnam quibusdam! Quo sequi voluptas eveniet molestias.</p>
            </div>
        </div>
    </div>

    <script>
        const tabs=document.querySelectorAll('.tab_btn');
        const tabs_contents=document.querySelectorAll('.tab_content');

        tabs.forEach((tab,index)=>{
            tab.addEventListener('click',function(e){
                tabs.forEach(tab=>{
                    tab.classList.remove('active');
                })
                tab.classList.add('active')

                const line=document.querySelector('.tab_header .line');
                line.style.width=e.target.offsetWidth+'px';
                line.style.left=e.target.offsetLeft+'px';

                tabs_contents.forEach(tab_content=>{
                    tab_content.classList.remove('active');
                })
                tabs_contents[index].classList.add('active')
            });
        })

    </script>

</body>
</html>